<template>
  <a-modal
    title="请扫码关联"
    :width="300"
    :visible="visible"
    :maskClosable="false"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
  >
    <div id="qrcode">
      <canvas id="canvas"></canvas>
    </div>


  </a-modal>
</template>

<script>
import QRCode from 'qrcode'
  export default {
    //--############  data() ###############&ndash;&gt;
    data() {
      return {
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 }
        },
        visible: false,
        confirmLoading: false,
        mdl: {},
        url:''

      }
    },
    props:[],
    //--############  data() ###############&ndash;&gt;
    components:{
      QRCode,
    },
    created() {

    },

    //--############  methods() ###############&ndash;&gt;
    methods: {
      edit(record) {
        this.isDisabled = true
        this.mdl = Object.assign({}, record)
        this.visible = true
        this.$nextTick(()=>{
          let canvas = document.getElementById('canvas')
          this.url = `${this.$baseURL}/common/open/storeUserLinkOpenId?storeUserId=${record.id}`
          QRCode.toCanvas(canvas,this.url,function(error) {
            console.log(error)
          })
        })

      },

      handleOk(){
        this.$emit('ok')
        this.close()
      },
      handleCancel() {
        this.close()
      },

      close() {
        this.$emit('close')
        this.visible = false
        this.mdl={}
      },

    },

    //--############  methods() ###############-->
  }
</script>

<style scoped>
  #qrcode{
  width: 183px;
  height: 170px;
  margin: 0 auto;
}


</style>
